﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BUS;
using Entity;

public partial class DoiMatKhau : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Username"] == null)
            Response.Redirect("Default.aspx");
        if (!IsPostBack)
        {
            lbThongBao.Visible = false;
        }
    }
    protected void btnLuu_Click(object sender, EventArgs e)
    {
        String cmnd = (String)Session["Username"];
        String mkcu = txtMKCu.Text;
        String mkmoi = txtMKMoi.Text;
        if (NhanVienBUS.DangNhap(cmnd, mkcu) != null)
        {
            NhanVienBUS.DoiMatKhau(cmnd, mkcu, mkmoi);
            lbThongBao.Text = "Thay dổi mật khẩu thành công";
            lbThongBao.Visible = true;
            lbThongBao.ForeColor = System.Drawing.Color.Blue;
            txtMKCu.Text = "";
            txtMKMoi.Text = "";
            txtMKMoi2.Text = "";
        }
        else
        {
            lbThongBao.Text = "Mật khẩu cũ không hợp lệ";
            lbThongBao.Visible = true;
            lbThongBao.ForeColor = System.Drawing.Color.Red;
            txtMKCu.Text = "";
            txtMKMoi.Text = "";
            txtMKMoi2.Text = "";
        }
    }
    protected void btnHuy_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
}
